package com.jy.rhin.infra.repo.node;

import com.jy.common.UIDWorker;
import com.jy.rhin.domain.document.node.NodeAuthenticationDao;
import com.jy.rhin.infra.repo.node.mapper.NodeAuthenticationMapper;
import com.jy.rhin.infra.repo.node.po.NodeAuthenticationPo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 *
 */
@Service
public class NodeAuthenticationDaoImpl implements NodeAuthenticationDao {

    @Resource
    UIDWorker uidWorker;
    @Resource
    private NodeAuthenticationMapper nodeAuthenticationMapper;


    @Override
    public Long save(NodeAuthenticationPo nodeAuthenticationPo) {
        nodeAuthenticationPo.setId(uidWorker.nextId());
        nodeAuthenticationPo.setNodeCode(nodeAuthenticationPo.getId().toString());
        nodeAuthenticationPo.setShenhezt("0");
        nodeAuthenticationPo.setZuofeibz("0");
        nodeAuthenticationPo.setCreatedTime(new Date());
        nodeAuthenticationPo.setUpdateTime(new Date());
        nodeAuthenticationMapper.insert(nodeAuthenticationPo);
        return nodeAuthenticationPo.getId();
    }

    @Override
    public Integer update(NodeAuthenticationPo nodeAuthenticationPo) {
        nodeAuthenticationPo.setUpdateTime(new Date());
        return  nodeAuthenticationMapper.updateById(nodeAuthenticationPo);
    }

}
